var num = 0;
var oBtn;
var oTxt;

window.onload = function (){
  oTxt = document.getElementById('txt');
  oBtn = document.getElementById('addBtn');

  if(sessionStorage.num){
      num = sessionStorage.num;
  }else{
      num = 0;
  }

  oBtn.onclick = function () {
      num++;
      sessionStorage.num = num;
      showNum();
  }
};
function showNum(){
    oTxt.innerHTML = num;
}